package com.gz.slin.system.controller;

import com.gz.slin.system.pojo.User;
import com.gz.slin.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/8/15.
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/load")
    public String load(HttpServletRequest request) {

        return "/admin/user/userList";
    }

    @RequestMapping("/list")
    @ResponseBody
    public Map<String, Object> list(HttpServletRequest request) {
        Map<String, Object> map = new HashMap<>();
        List<User> userList = this.userService.selectAll();
        request.setAttribute("userList", userList);
        map.put("rows", userList);
        map.put("page", 1);
        map.put("pageSize", 5);
        map.put("total", 10);
        return map;
    }


}
